package javabase.collection.list.thread;

import java.util.Iterator;
import java.util.Vector;

public class ArrayListSecurity {

	public static void main(String[] args) {
		
		Vector<String> list = new Vector<String>();
		
		// 调用Collections.synchronizedList 将不安全的List包装成安全的
        //抛出java.util.ConcurrentModificationException
		//list = Collections.synchronizedList(list);
		
		ListRun myRunable0 = new ListRun();
		//ListRun myRunable1 = new ListRun();
		Thread myThread0 = new Thread(myRunable0);
		Thread myThread1 = new Thread(myRunable0);
		myThread0.start();
		myThread1.start();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		Iterator<String> e = list.iterator();
		while (e.hasNext()) {
			System.out.print(e.next());
		}
		System.out.println("\n------无比华丽的分割线------");
	}

}
